"""Definition of the shelf content type
"""

from zope.interface import implements
from Products.ATContentTypes.content.base import registerATCT
from Products.ePubBook.config import PROJECTNAME
from Products.ePubBook.interfaces import IShelf
from Products.ATContentTypes.content.folder import ATFolder

from Products.ePubBook import ePubBookMessageFactory as _
from Products.Archetypes import atapi
from Products.ATContentTypes.content.folder import ATFolderSchema
from Products.ATContentTypes.content.schemata import finalizeATCTSchema

ShelfSchema = ATFolderSchema.copy() + atapi.Schema((
    atapi.TextField('about',
                    required = True,
                    searchable = True,
                    allowable_content_types=('text/plain',),
                    widget = atapi.TextAreaWidget(
                        label = _(u'label_info_about',default=u'About'),
                        macro='my_textarea_widget',
                    )
    ),
    atapi.ImageField('loadingpic1',
                    required = True,
                    default_output_type='image/jpeg',
                    allowable_content_types=('image/*',),
                    sizes= {
                            'mini'    : (180, 180),                            
                    },
                    widget = atapi.ImageWidget(
                        label = _(u'label_info_loadingpic',default = u'loading pic'),
                        macro = "my_image_widget"
                        
                    )                   
    ),
    atapi.ImageField('loadingpic2',
                    default_output_type='image/jpeg',
                    allowable_content_types=('image/*',),
                    sizes= {
                            'mini'    : (180, 180),                            
                    },
                    widget = atapi.ImageWidget(
                        label = _(u'label_info_loadingpic',default = u'loading pic'),
                        macro = "my_image_widget"
                        
                    )                   
    ),
    atapi.ImageField('logo1',
                    required = True,
                    default_output_type='image/jpeg',
                    allowable_content_types=('image/*',),
                    sizes= {
                            'mini'    : (180, 180),                            
                    },
                    widget = atapi.ImageWidget(
                        label = _(u'label_info_logo',default = u'logo'),
                        macro = "my_image_widget"
                        
                    )                   
    ),
    atapi.ImageField('logo2',
                    default_output_type='image/jpeg',
                    allowable_content_types=('image/*',),
                    sizes= {
                            'mini'    : (180, 180),                            
                    },
                    widget = atapi.ImageWidget(
                        label = _(u'label_info_logo',default = u'logo'),
                        macro = "my_image_widget"
                        
                    )                   
    ),
))
ShelfSchema['title'].required = False
finalizeATCTSchema(ShelfSchema)

class EpubShelf(ATFolder):
    """ A shelf ,which has books, news etc.."""
    portal_type = 'EpubShelf'
    archetype_name = 'EpubShelf'
    _atct_newTypeFor = {'portal_type' : 'CMF Shelf', 'meta_type' : 'Epub Shelf'}
    
    implements(IShelf)
    schema = ShelfSchema

registerATCT(EpubShelf,PROJECTNAME)